﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LdapPravilaSeznam.aspx.cs" Inherits="Sio.Mdm.Web.Instalacija.LdapPravilaSeznam" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script type="text/javascript">
        
        function PrepareParamsAndShowDialog(eventId, grid, dialog) {

            if (eventId == 'Add') {
                dialog.show();
            }
            if (eventId == 'Edit')
                var id = getSelectedPraviloID(grid);
                dialog.addParameter('PraviloID', id);                
                dialog.show();
            }
        
        function getSelectedPraviloID(grid) {            
            if (grid.getSelectionModel().selections.length == 1) {
                var id = grid.getSelectionModel().selections.items[0].id;
                return id;
            }
            else { return 0; }
        }
        
        var LdapTipiRenderer = function(value) {
            var r = StoreLdapTipi.getById(value);
            if (Ext.isEmpty(r)) { return ""; }
            return r.data.Naziv;
        };

        function setButtons() {
            btnEdit.setDisabled(false);
            btnRemove.setDisabled(false);
            btnPreveriPripadnost.setDisabled(false);
            btnSync.setDisabled(false);
            btnSyncDelete.setDisabled(false);          
        }
    </script>    
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
    <ext:Store ID="StoreLdapTipi" runat="server">
	<Reader>
		<ext:ArrayReader IDProperty="LdapTipID">
			<Fields>
				<ext:RecordField Name="LdapTipID" Type="Int" />
				<ext:RecordField Name="Naziv" Type="String" />
			</Fields>
		</ext:ArrayReader>
	</Reader>
    </ext:Store>
    
    <ext:Viewport ID="Viewport1" runat="server" Layout="Fit">
    <Content>
        <sio:GridPanel ID="GridPravilaSeznam" runat="server" StripeRows="true" TrackMouseOver="true" AutoExpandColumn="Opis">                
                <Store>
                    <ext:Store ID="StorePravilaSeznam" runat="server">
                        <Reader>
                            <ext:JsonReader IDProperty="LdapPraviloID">
                                <Fields>
                                    <ext:RecordField Name="LdapPraviloID" Type="Int" />                                    
                                    <ext:RecordField Name="Ime" Type="String" />
                                    <ext:RecordField Name="Opis" Type="String" />
                                    <ext:RecordField Name="BaseDN" Type="String" />  
                                    <ext:RecordField Name="StreznikIme" Type="String" /> 
                                    <ext:RecordField Name="StreznikOpis" Type="String" />  
                                    <ext:RecordField Name="PredlogaIme" Type="String" /> 
                                    <ext:RecordField Name="PredlogaOpis" Type="String" /> 
                                    <ext:RecordField Name="Aktivno" Type="Boolean" />  
                                    <ext:RecordField Name="SinID" Type="Int" />
                                    <ext:RecordField Name="SinObjektID" Type="Int" />
                                    <ext:RecordField Name="SinObjektTipID" Type="Int" />  
                                    <ext:RecordField Name="TipObjektaNaziv" Type="String" />  
                                    <ext:RecordField Name="OrgarnizacijaNaziv" Type="String" />                                                                                                                                 
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column ColumnID="LdapPraviloID" Hidden="true" Hideable="false" DataIndex="LdapPraviloID" Header="PraviloID">
                        </ext:Column>
                        <ext:Column ColumnID="Organizacija" Hidden="false" Hideable="true" DataIndex="OrgarnizacijaNaziv" Header="Organizacija">
                        </ext:Column>
                        <ext:Column ColumnID="Ime" Hidden="false" Hideable="false" DataIndex="Ime" Header="Ime" Width="150">
                        </ext:Column>                        
                        <ext:Column ColumnID="Opis" Hidden="false" Hideable="false" DataIndex="Opis" Header="Opis">
                        </ext:Column>  
                        <ext:Column ColumnID="StreznikIme" Hidden="false" Hideable="true" DataIndex="StreznikIme" Header="Streznik">
                        </ext:Column>   
                        <ext:Column ColumnID="PredlogaIme" Hidden="false" Hideable="true" DataIndex="PredlogaIme" Header="Predloga">
                        </ext:Column>                                             
                        <ext:Column ColumnID="BaseDN" Hidden="false" Hideable="true" DataIndex="BaseDN" Header="Base DN" Width="250">
                        </ext:Column>  
                        <ext:Column ColumnID="TipObjektaNaziv" Hidden="false" Hideable="true" DataIndex="TipObjektaNaziv" Header="Entiteta" Width="70">                            
                        </ext:Column>                        
                        <ext:CheckColumn ColumnID="Aktivno" Hidden="false" Hideable="true" DataIndex="Aktivno" Header="Aktivno" Width="50">                        
                        </ext:CheckColumn>                                 
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server">                    
						<Listeners>
							<RowSelect Handler="setButtons();" />
						</Listeners>
					</ext:RowSelectionModel>
                </SelectionModel>
                <TopBar>
                <ext:Toolbar ID="Toolbar1" runat="server">
                <Items>
                    <sio:Button runat="server" ID="Dodaj" Text="Dodaj" Icon="Add">                                
                        <Listeners>
                            <Click Handler="PrepareParamsAndShowDialog('Add',#{GridPravilaSeznam},#{DialogPravilaPodrobno});" />
                        </Listeners>
                    </sio:Button>
                    <sio:Button runat="server" ID="btnEdit" Text="Uredi" Icon="NoteEdit" Disabled="true">                                
                        <Listeners>
                            <Click Handler="PrepareParamsAndShowDialog('Edit',#{GridPravilaSeznam},#{DialogPravilaPodrobno});" />
                        </Listeners>
                    </sio:Button>
                    <sio:Button runat="server" ID="btnRemove" Text="Odstrani" Icon="Delete" Disabled="true">
                        <DirectEvents>
                            <Click OnEvent="OdstraniZapise">
                                <Confirmation ConfirmRequest="true" Message="Odstranim izbrane zapise?" />
                                <ExtraParams>
                                    <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridPravilaSeznam}.getRowsValues({selectedOnly:true}))" />
                                </ExtraParams>
                            </Click>
                        </DirectEvents>
                    </sio:Button>
                    <ext:ToolbarSeparator />
                    <sio:Button runat="server" ID="btnPreveriPripadnost" Text="Preveri pripadnost" Icon="AsteriskYellow" Disabled="true">
                        <DirectEvents>
                            <Click OnEvent="PreveriPripadnost">
                                <ExtraParams>
                                    <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridPravilaSeznam}.getRowsValues({selectedOnly:true}))" />    
                                </ExtraParams>    
                            </Click>    
                        </DirectEvents>
                    </sio:Button>
                    <sio:Button runat="server" ID="btnSync" Text="Sinhroniziraj po pravilu" Icon="AsteriskOrange" Disabled="true">
                        <DirectEvents>
                            <Click OnEvent="SinhronizacijaPoPravilu">
                                <EventMask ShowMask="true" Target="Page" Msg="Prosimo počakajte, poteka sinhronizacija podatkov po pravilu..." MinDelay="200" />                                
                                <ExtraParams>
                                    <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridPravilaSeznam}.getRowsValues({selectedOnly:true}))" />    
                                </ExtraParams>    
                            </Click>    
                        </DirectEvents>
                    </sio:Button>                    
                    <sio:Button runat="server" ID="btnSyncDelete" Text="Briši po pravilu" Icon="AsteriskRed" Disabled="true">
                        <DirectEvents>
                            <Click OnEvent="BrisanjePoPravilu">
                                <EventMask ShowMask="true" Target="Page" Msg="Prosimo počakajte, poteka brisanje podatkov po pravilu..." MinDelay="200" />                                
                                <ExtraParams>
                                    <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridPravilaSeznam}.getRowsValues({selectedOnly:true}))" />    
                                </ExtraParams>    
                            </Click>    
                        </DirectEvents>                                                
                    </sio:Button>                                                            
                 </Items>
                </ext:Toolbar>
                </TopBar>
         </sio:GridPanel>
    
    </Content>
    </ext:Viewport>
    
    <sio:Dialog runat="server" ID="DialogPravilaPodrobno"
		Width="600"
		Height="400"
		Url="LdapPravilaPodrobno.aspx"
		DialogButtons="SaveClose"
    Title="Pravila Podrobno">
        <Parameters>
			<ext:Parameter Name="PraviloID" Value="0" Mode="Value" />
			<ext:Parameter Name="OrgarnizacijaID" Value="0" Mode="Value" />
		</Parameters>
		<Listeners>
            <Hide Handler="#{StorePravilaSeznam}.reload();" />
        </Listeners>
	</sio:Dialog>
    
    </form>
</body>
</html>
